$(function() {
  console.log('in topic.js');

  $('#btnBack').click(function(){
    location.href = 'main.html';
  });

  var page = { pageSize: 5, pageNumber: 1 };

  function query() {
    mydialog.showWait('数据查询中...', '等待');
    dataService.send(
      '/tbTopic/queryAll',
      {
        'page.pageSize': page.pageSize,
        'page.pageNumber': page.pageNumber
      },
      function(data) {
        console.log(data);
        mydialog.hideWait();
        if (!data.success) {
          mydialog.showAlert(data.message, '信息');
          return;
        }
        page = data.dataMap.page; //分页信息更新
        //处理分类下拉列表
        $('#selType').html('');
        $.each(data.dataMap.subjects, function(i, v) {
          var $option=$(document.createElement('option'));
          $option.val(v.sid);
          $option.append(v.sname);
          $('#selType').append($option);
        });
        
      }
    );
  }

  query();
});
